package com.hrb.monkey.network.http;

import com.hrb.commonsdk.okhttp.CommonOkHttpClient;

import com.hrb.commonsdk.okhttp.HttpConstant;
import com.hrb.commonsdk.okhttp.listener.DisposeDataHandle;
import com.hrb.commonsdk.okhttp.listener.DisposeDataListener;
import com.hrb.commonsdk.okhttp.listener.DisposeDownloadListener;
import com.hrb.commonsdk.okhttp.request.CommonRequest;
import com.hrb.commonsdk.okhttp.request.RequestParams;
import com.hrb.monkey.record.FirsFragmentRecord;

public class RequestCenter {

    //get
    public static void getRequest(String url, RequestParams params, DisposeDataListener listener, Class<?> clazz) {
        CommonOkHttpClient.get(CommonRequest.createGetRequest(url, params), new DisposeDataHandle(listener,clazz));
    }
    //根据参数发送所有post请求
    public static void postRequest(String url, RequestParams params, DisposeDataListener listener, Class<?> clazz) {
        RequestParams heads=new RequestParams();
        heads.put("Content-Type","application/json");
        CommonOkHttpClient.post(CommonRequest.createPostRequest(url, params,heads), new DisposeDataHandle(listener,clazz));
    }
    public static void requestRecommandData(DisposeDataListener listener) {
        RequestCenter.getRequest(HttpConstants.FIRST_PAGE_LIST, null, listener, FirsFragmentRecord.class);
    }

    public static void downloadFile(String url, String path, DisposeDownloadListener listener) {
        CommonOkHttpClient.downloadFile(CommonRequest.createGetRequest(url, null),
                new DisposeDataHandle(listener, path));
    }

    public static void postMessge(String url, RequestParams params, DisposeDataListener listener ,Class<?> clazz) {
        CommonOkHttpClient.post(CommonRequest.createPostRequest(url,params),new DisposeDataHandle(listener,clazz));
        //https://www.easy-mock.com/mock/5a4d85d3e5f9cd651a7fbe77/test/postuserinfo
    }
    public  static void  userLogin(RequestParams params,DisposeDataListener listener,Class<?> clazz){
        RequestCenter.postRequest(HttpConstants.USER_LOGIN,params,listener,clazz);
    }
}
